<?
include_once "JCAT_ItemIterator.class.php" ;

class JCAT_ItemSelectedIterator extends JCAT_ItemIterator
{
	function JCAT_ItemSelectedIterator($nBoxClm,$aModel,$aItem=null)
	{
		$this->nBoxClm = $nBoxClm ;
		$this->JCAT_ItemIterator($aModel,$aItem) ;
	}
	
	private $nBoxClm ;
	
	function IsSelected($aItem)
	{ return ($aItem and $this->aModel->get_value($aItem,$this->nBoxClm)) ; }
	
	function First()
	{
		JCAT_ItemIterator::First() ;
		while( !$this->IsDone() )
		{
			$aItem = $this->Current() ;
			if( $this->IsSelected($aItem) )
				return $aItem ;
			JCAT_ItemIterator::Next() ;
		}
	}
	
	function Next()
	{
		$aRetItem = $this->Current() ;
		
		while(!$this->IsDone())
		{
			JCAT_ItemIterator::Next() ;
			$aItem = $this->Current() ;
			if( $this->IsSelected($aItem) )
				break ;
		}
		
		return $aRetItem ;
	}
}
?>